<!DOCTYPE html>
<html lang="en-us">
  <head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="robots" content="noodp"/>
  <meta name="author" content="Mr.wei">
  
  
  
  <link rel="prev" href="http://blog.mr-wei.cn/2019/linux-grep-%E5%91%BD%E4%BB%A4/" />
  <link rel="next" href="http://blog.mr-wei.cn/2019/%E5%A4%A7%E7%AB%AF%E4%B8%8E%E5%B0%8F%E7%AB%AF/" />
  <link rel="canonical" href="http://blog.mr-wei.cn/2019/linux-scp-rsync/" />
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  <link rel="manifest" href="/site.webmanifest">
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
  <meta name="msapplication-TileColor" content="#da532c">
  <meta name="theme-color" content="#ffffff">
  <title>
       
       
           Linux  scp和rsync 命令 | Mr.wei
       
  </title>
  <meta name="title" content="Linux  scp和rsync 命令 | Mr.wei">
    
  
  <link rel="stylesheet" href="/font/iconfont.css">
  <link rel="stylesheet" href="/css/main.min.css">


  
  
 

<script type="application/ld+json">
 "@context" : "http://schema.org",
    "@type" : "BlogPosting",
    "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "http:\/\/blog.mr-wei.cn"
    },
    "articleSection" : "posts",
    "name" : "Linux  scp和rsync 命令",
    "headline" : "Linux  scp和rsync 命令",
    "description" : "数据同步 scp  作用 远程文件的安全拷贝\n 格式\nscp [参数] [源路径] [目标路径]  选项\n   选项 说明     -r 递归复制整个目录   -C 允许压缩   -P 指定传输端口号    示例\n#从远程服务器复文件a.tar.gz到本地目录 scp mr-wei@192.168.1.1:\/home\/mr-wei\/a.tar.gz \/home\/mr-wei\/ #复制本地文件b.tar.gz到远程服务器 scp \/home\/mr-wei\/b.tar.gz mr-wei@192.168.1.1:\/home\/mr-wei\/   rsync  作用 同步文件\n 格式\nrsync [参数] [源路径] [目标路径]  选项\n   选项 说明     -r 递归同步   -P 显示同步过程   -u 如果目标路径中的文件比源路径中的 文件新则不同步   -z 传输时压缩   -l 保留软连接    注意",
    "inLanguage" : "en-us",
    "author" : "Mr.wei",
    "creator" : "Mr.wei",
    "publisher": "Mr.wei",
    "accountablePerson" : "Mr.wei",
    "copyrightHolder" : "Mr.wei",
    "copyrightYear" : "2019",
    "datePublished": "2019-09-02 09:11:02 \x2b0800 CST",
    "dateModified" : "2019-09-02 09:11:02 \x2b0800 CST",
    "url" : "http:\/\/blog.mr-wei.cn\/2019\/linux-scp-rsync\/",
    "wordCount" : "63",
    "keywords" : [ "scp","rsync","linux command", "Mr.wei"]
}
</script>

</head>

  


  <body class="">
    <div class="wrapper">
        <nav class="navbar">
    <div class="container">
        <div class="navbar-header header-logo">
        	<a href="javascript:void(0);" class="theme-switch"><i class="iconfont icon-xihuan"></i></a>&nbsp;<a href="http://blog.mr-wei.cn">Mr.wei</a>
        </div>
        <div class="menu navbar-right">
                
                
                <a class="menu-item" href="/posts/" title="">Blog</a>
                
                <a class="menu-item" href="http://balance.mr-wei.cn" title="">BalanceCar</a>
                
                <a class="menu-item" href="/categories/" title="">Categories</a>
                
                <a class="menu-item" href="/tags/" title="">Tags</a>
                
                <a class="menu-item" href="/about/" title="About">About</a>
                
        </div>
    </div>
</nav>
<nav class="navbar-mobile" id="nav-mobile" style="display: none">
     <div class="container">
        <div class="navbar-header">
            <div>  <a href="javascript:void(0);" class="theme-switch"><i class="iconfont icon-xihuan"></i></a>&nbsp;<a href="http://blog.mr-wei.cn">Mr.wei</a></div>
            <div class="menu-toggle">
                <span></span><span></span><span></span>
            </div>
        </div>
     
          <div class="menu" id="mobile-menu">
                
                
                <a class="menu-item" href="/posts/" title="">Blog</a>
                
                <a class="menu-item" href="http://balance.mr-wei.cn" title="">BalanceCar</a>
                
                <a class="menu-item" href="/categories/" title="">Categories</a>
                
                <a class="menu-item" href="/tags/" title="">Tags</a>
                
                <a class="menu-item" href="/about/" title="About">About</a>
                
        </div>
    </div>
</nav>







    	 <main class="main">
          <div class="container">
      		
<article class="post-warp" itemscope itemtype="http://schema.org/Article">
    <header class="post-header">
        <h1 class="post-title" itemprop="name headline">Linux  scp和rsync 命令</h1>
        <div class="post-meta">
                Written by <a itemprop="name" href="http://blog.mr-wei.cn" rel="author">Mr.wei</a> with ♥ 
                <span class="post-time">
                on <time datetime=2019-09-02 itemprop="datePublished">September 2, 2019</time>
                </span>
                in
                <i class="iconfont icon-folder"></i>
                <span class="post-category">
                        
                </span>
        </div>
    </header>
    <div class="post-content">
        

        

        
        
     
          
          
          

          
          
          

          

<h1 id="数据同步">数据同步</h1>

<h2 id="scp">scp</h2>

<ul>
<li><p>作用
远程文件的安全拷贝</p></li>

<li><p>格式</p>

<pre><code class="language-shell">scp [参数] [源路径] [目标路径]
</code></pre></li>

<li><p>选项</p>

<table>
<thead>
<tr>
<th>选项</th>
<th>说明</th>
</tr>
</thead>

<tbody>
<tr>
<td>-r</td>
<td>递归复制整个目录</td>
</tr>

<tr>
<td>-C</td>
<td>允许压缩</td>
</tr>

<tr>
<td>-P</td>
<td>指定传输端口号</td>
</tr>
</tbody>
</table></li>

<li><p>示例</p>

<pre><code class="language-shell">#从远程服务器复文件a.tar.gz到本地目录
scp mr-wei@192.168.1.1:/home/mr-wei/a.tar.gz /home/mr-wei/
#复制本地文件b.tar.gz到远程服务器
scp /home/mr-wei/b.tar.gz mr-wei@192.168.1.1:/home/mr-wei/
</code></pre></li>
</ul>

<h2 id="rsync">rsync</h2>

<ul>
<li><p>作用
同步文件</p></li>

<li><p>格式</p>

<pre><code class="language-shell">rsync  [参数] [源路径] [目标路径]
</code></pre></li>

<li><p>选项</p>

<table>
<thead>
<tr>
<th>选项</th>
<th>说明</th>
</tr>
</thead>

<tbody>
<tr>
<td>-r</td>
<td>递归同步</td>
</tr>

<tr>
<td>-P</td>
<td>显示同步过程</td>
</tr>

<tr>
<td>-u</td>
<td>如果目标路径中的文件比源路径中的 文件新则不同步</td>
</tr>

<tr>
<td>-z</td>
<td>传输时压缩</td>
</tr>

<tr>
<td>-l</td>
<td>保留软连接</td>
</tr>
</tbody>
</table></li>

<li><p>注意</p>

<ul>
<li>传输过程中同步的文件将修改自身名称为.name.xxxx以隐藏，可以使用ls -a 查看</li>
<li>传输过程中如果中断，则文件自动改回name</li>
<li>继续同步时再次改名.name.xxxx隐藏 传输，断点续传
<br /></li>
</ul></li>

<li><p>示例</p>

<pre><code class="language-shell">#通过ssh协议同步远程服务器上的a.tar.gz到本地
rsync -P --rsh=ssh mr-wei@192.168.1.1:/home/mr-wei/a.tar.gz /home/mr-wei
</code></pre></li>
</ul>

    </div>

    <div class="post-copyright">
             
            <p class="copyright-item">
                <span>Author:</span>
                <span>Mr.wei </span>
                </p>
            
           
             
            <p class="copyright-item">
                    <span>Link:</span>
                    <a href=http://blog.mr-wei.cn/2019/linux-scp-rsync/>http://blog.mr-wei.cn/2019/linux-scp-rsync/</span>
            </p>
            
             
            <p class="copyright-item lincese">
                本文采用<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" #target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可
            </p>
            
    </div>

  
    <div class="post-tags">
        
            <section>
            <i class="iconfont icon-tag"></i>Tag(s): 
            
            <span class="tag"><a href="http://blog.mr-wei.cn/tags/scp/">
                    #scp</a></span>
            
            <span class="tag"><a href="http://blog.mr-wei.cn/tags/rsync/">
                    #rsync</a></span>
            
            <span class="tag"><a href="http://blog.mr-wei.cn/tags/linux-command/">
                    #linux command</a></span>
            
            </section>
        
        <section>
                <a href="javascript:window.history.back();">back</a></span> · 
                <span><a href="http://blog.mr-wei.cn">home</a></span>
        </section>
    </div>

    <div class="post-nav">
        
        <a href="http://blog.mr-wei.cn/2019/linux-grep-%E5%91%BD%E4%BB%A4/" class="prev" rel="prev" title="Linux grep 命令"><i class="iconfont icon-left"></i>&nbsp;Linux grep 命令</a>
         
        
        <a href="http://blog.mr-wei.cn/2019/%E5%A4%A7%E7%AB%AF%E4%B8%8E%E5%B0%8F%E7%AB%AF/" class="next" rel="next" title="大端与小端">大端与小端&nbsp;<i class="iconfont icon-right"></i></a>
        
    </div>

    <div class="post-comment">
          
                 
          
    </div>
</article>
          </div>
		   </main>
      <footer class="footer">
    <div class="copyright">
        &copy;
        
        <span itemprop="copyrightYear">2018 - 2019</span>
        
        <span class="with-love">
    	 <i class="iconfont icon-love"></i> 
         </span>
         
            <span class="author" itemprop="copyrightHolder"><a href="http://blog.mr-wei.cn">Mr.wei</a> | </span> 
         

         
            <a href="http://www.miibeian.gov.cn/" target="_blank" rel="external nofollow">冀ICP备 - 18032379号 </a> |
         
		  <span>Powered by <a href="https://gohugo.io/" target="_blank" rel="external nofollow">Hugo</a> & <a href="https://github.com/liuzc/leaveit" target="_blank" rel="external nofollow">LeaveIt</a></span> 
    </div>

	
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [['$','$'], ['\\(','\\)']],
            displayMath: [['$$','$$'], ['\[','\]']],
            processEscapes: true,
            processEnvironments: true,
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            TeX: {
                equationNumbers: { autoNumber: "AMS" },
                extensions: ["AMSmath.js", "AMSsymbols.js"]
            }
        }
    });
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
	
	

</footer>












    
    
    <script src="/js/vendor_no_gallery.min.js" async=""></script>
    
  



     </div>
  </body>
</html>
